package com.ljk.study14swagger3.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *
 * </p>
 *
 * @author ljk
 * @date 2021/4/18 0:36
 */
@Api(value = "初始化接口类", tags = "初始化接口类标签")
@RestController
@RequestMapping("/index")
public class IndexController {

    @ApiOperation(value = "返回打招呼", notes = "包含请求的详细信息")
    @RequestMapping("/sayHi")
    @ApiImplicitParam(name = "name",value = "患者姓名")
    public Map sayHi(@RequestParam(name = "name",required = true) String name, HttpServletRequest request) {
        HashMap<String, String> map = new HashMap<>(3);
        map.put("code", "200");
        map.put("msg", "成功");
        map.put("data", String.format("[请求返回]:hello,%s.你当前采用的是%s方法进行的请求", name, request.getMethod()));
        return map;
    }
}
